Trò chơi đua xe động vật trong UNITY Engine
114.924 lượt xem;
- TouchText.cs
- MainMenu /
- AnimalRacing /
- Scripts /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3 using UnityEngine.SceneManagement;
4 namespace MainMenu
5 {
6 public class TouchText : MonoBehaviour
7 {
8 public GameObject text;
9
10 public void Start()
11 {
12 Data.InitData();
13 InputController.Enabled = false;
14
15 gameObject.GetComponent<Actor>().addAction(new ActionSequence(
16 new ActionDelay(2),
17 new ActionMoveTo(0, -1.85f, 0.1f, Interpolation.sine),
18 new ActionRunnable(delegate() { enableInput(); })
19 ));
20
21 text.GetComponent<Actor>().addAction(new ActionSequence(new ActionDelay(2.1f),
22 new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
23 new ActionColorTo(1, 1, 1, 1, 0.1f), new ActionColorTo(1, 1, 1, 0, 0.1f)
24 ))));
25 }
26
27 public void enableInput()
28 {
29 InputController.Enabled = true;
30 InputController.Name = InputNames.MAINMENU;
31 }
32
33 public void LateUpdate()
34 {
35 if (InputController.Enabled && InputController.Name == InputNames.MAINMENU)
36 {
37 if (Input.GetButtonDown("Fire1") && InputController.IsScreen)
38 {
39 SceneManager.LoadScene("MapScreen");
40 }
41 else if (Input.GetMouseButtonUp(0))
42 {
43 InputController.IsScreen = true;
44 }
45 }
46 }
47 }
48 }
2 using System.Collections;
3 using UnityEngine.SceneManagement;
4 namespace MainMenu
5 {
6 public class TouchText : MonoBehaviour
7 {
8 public GameObject text;
9
10 public void Start()
11 {
12 Data.InitData();
13 InputController.Enabled = false;
14
15 gameObject.GetComponent<Actor>().addAction(new ActionSequence(
16 new ActionDelay(2),
17 new ActionMoveTo(0, -1.85f, 0.1f, Interpolation.sine),
18 new ActionRunnable(delegate() { enableInput(); })
19 ));
20
21 text.GetComponent<Actor>().addAction(new ActionSequence(new ActionDelay(2.1f),
22 new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
23 new ActionColorTo(1, 1, 1, 1, 0.1f), new ActionColorTo(1, 1, 1, 0, 0.1f)
24 ))));
25 }
26
27 public void enableInput()
28 {
29 InputController.Enabled = true;
30 InputController.Name = InputNames.MAINMENU;
31 }
32
33 public void LateUpdate()
34 {
35 if (InputController.Enabled && InputController.Name == InputNames.MAINMENU)
36 {
37 if (Input.GetButtonDown("Fire1") && InputController.IsScreen)
38 {
39 SceneManager.LoadScene("MapScreen");
40 }
41 else if (Input.GetMouseButtonUp(0))
42 {
43 InputController.IsScreen = true;
44 }
45 }
46 }
47 }
48 }